package com.yanwq.sayhi.service;

import com.yanwq.sayhi.tool.ImageTool;

import java.io.File;
import java.io.IOException;

/**
 * 作者：yanweiqiang。
 * 日期：2016/8/4 0004。
 */
public abstract class AbsCSService implements ItfCSService {

    @Override
    public String[] uploadPictureBatch(File file) throws
            IOException {
        String[] urls = new String[3];

        String thumbPath = file.getParentFile()
                .getPath()
                .concat("/thumb-")
                .concat(file.getName());
        String mediumPath = file.getParentFile()
                .getPath()
                .concat("/medium-")
                .concat(file.getName());

        ImageTool.scale(file,
                new File(thumbPath),
                80);
        ImageTool.scale(file,
                new File(mediumPath),
                240);

        urls[0] = uploadPicture(new File(thumbPath));
        urls[1] = uploadPicture(new File(mediumPath));
        urls[2] = uploadPicture(file);

        return urls;
    }
}
